package abcy.cloud.syscoreserver.controller;

import abcy.cloud.blogcommon.resp.ResponseEntity;
import abcy.cloud.syscoreserver.dto.req.SysUserAddReqDto;
import abcy.cloud.syscoreserver.dto.req.SysUserSelectReqDto;
import abcy.cloud.syscoreserver.dto.resp.SysUserSelectRespDto;
import abcy.cloud.syscoreserver.services.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping(value = "sysuser")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @PostMapping(value = "/addSysUser")
    public ResponseEntity addSysUser(@RequestBody SysUserAddReqDto sysUserAddReqDto) {
        boolean flag = sysUserService.addSysUser(sysUserAddReqDto);
        return ResponseEntity.success("新增成功！");
    }

    @PostMapping(value = "/getUserInfoByUserName")
    public Map<String, Object> selectSysUserByUserName(@RequestBody SysUserSelectReqDto sysUserSelectReqDto) {
        return sysUserService.selectSysUserByUserName(sysUserSelectReqDto);
    }

    @PostMapping(value = "/getUserByUserName")
    public Map<String, Object> selectUserByUserName(@RequestBody SysUserSelectReqDto sysUserSelectReqDto) {
        return sysUserService.selectSysUserByUserName(sysUserSelectReqDto);
    }

    @PostMapping(value = "/test")
    public Map<String, Object> test() {
        return new HashMap<>();
    }
}
